﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DrugStorehouseMIS.BLL;

namespace DrugStorehouseMIS.StockInAndOutManager
{
    public partial class frmTransferIn : Form
    {
        public frmTransferIn()
        {
            InitializeComponent();
        }

        private void frmTransferIn_Load(object sender, EventArgs e)
        {
            LoadPageSize();
            LoadDataGridView();
        }

        #region 菜单栏
        private void tsBtnInNew_Click(object sender, EventArgs e)
        {

        }

        private void tsBtnInEdit_Click(object sender, EventArgs e)
        {

        }

        private void tsBtnInDelete_Click(object sender, EventArgs e)
        {

        }

        private void tsBtnInPrint_Click(object sender, EventArgs e)
        {

        }

        #endregion

        #region 查询方式

        private void btnSerach_Click(object sender, EventArgs e)
        {
            LoadDataGridView();
        }

        private void btnReset_Click(object sender, EventArgs e)
        {

        }

        #endregion

        #region 导航

        private void btnFirst_Click(object sender, EventArgs e)
        {
            nudInPageIndex.Value = 1;
        }

        private void btnPrevious_Click(object sender, EventArgs e)
        {
            if (nudInPageIndex.Value > 1)
                nudInPageIndex.Value--;
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if (nudInPageIndex.Value < nudInPageIndex.Maximum)
                nudInPageIndex.Value++;
        }

        private void btnLast_Click(object sender, EventArgs e)
        {
            nudInPageIndex.Value = nudInPageIndex.Maximum;
        }

        #endregion

        #region 表
        private void dgvIn_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                txtInfoInNum.Text = dgvIn.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtFilterInTypeName.Text = dgvIn.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtInfoInDate.Text = dgvIn.Rows[e.RowIndex].Cells[2].Value.ToString();
                txtInfoDrugName.Text = dgvIn.Rows[e.RowIndex].Cells[3].Value.ToString();
            }
        }
        #endregion

        public void LoadPageSize()
        {
            cbxInPageSize.Items.Clear();
            cbxInPageSize.Items.Add(2);
            cbxInPageSize.Items.Add(4);
            cbxInPageSize.Items.Add(6);
            cbxInPageSize.SelectedIndex = 0;
        }

        public void LoadListText()
        {
            int RecordCount = 1;
            if (RecordCount == 0)
            {
                nudInPageIndex.Maximum = 1;
                txtInRecordCount.Text = "0";
                txtInPageCount.Text = "0";
                return;
            }
            int PageCount = 0;
            PageCount = RecordCount / Int32.Parse(this.cbxInPageSize.Text);
            if (RecordCount % Int32.Parse(this.cbxInPageSize.Text) > 0)
                PageCount++;
            txtInPageCount.Text = PageCount.ToString();
            txtInRecordCount.Text = RecordCount.ToString();
            nudInPageIndex.Maximum = PageCount;
            if (nudInPageIndex.Value > PageCount) nudInPageIndex.Value = PageCount;
        }

        public void LoadDataGridView()
        {
            //DataTable dt = StockInBill.GetStockInDisplay((int)nudInPageIndex.Value, Int32.Parse(cbxInPageSize.Text), txtFilterInTypeName.Text, txtFilterInNum.Text);
            //dgvIn.DataSource = dt;
        }

        private void tspStockIn_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }
    }
}